package com.czk.utils;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/4/20 11:42
 */
public class UnsafeAccessor {
    private static Unsafe unsafe;

    static {
        try {
            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
            theUnsafe.setAccessible(true);
            unsafe = (Unsafe) theUnsafe.get(null);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static Unsafe getUnsafe() {
        return unsafe;
    }
}
